package ProcessManager;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class ProcessSocket {

	public static void main(String args[]) {
		Socket sk;
		try {
			sk = new Socket("127.0.0.1", 9999);
			System.out.println(sk);
			PrintStream sout = System.out;
			BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
			BufferedReader is = new BufferedReader(new InputStreamReader(sk.getInputStream()));
			PrintStream os = new PrintStream(sk.getOutputStream());

			String readline = sin.readLine();
			while (!readline.equals("bye")) {
				sout.println("client:" + readline);
				os.println(readline);
				os.flush();
				sout.println("server:" + is.readLine());
				sout.flush();
				readline = sin.readLine();
			}
			os.close();
			is.close();
			sk.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
